package com.hrms.web.sys_user.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.time.LocalDateTime;
import java.util.Collection;

/**
 * @Title: SysUser
 * @Author zhanji
 * @Package com.hrms.web.sys_user.entity
 * @description: 用户实体类
 */
@Data
@TableName("sys_user")
public class SysUser implements UserDetails {
    @TableId(type = IdType.AUTO)
    private Long userId;
    private String username;
    private String password;
    private String email;
    private String sex;
    private String nickname;
    private String phone;
    private String avatar;
    //不属于用户表
    @TableField(exist = false)
    private String roleId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    private String isAdmin;
    //账户是否过期（1 未过期 0 已过期）
    private boolean isAccountNonExpired =true;
    //账户是否锁定（1 未锁定 0 已锁定）
    private boolean isAccountNonLocked = true;
    //账户是否过期（1 未过期 0 已过期）
    private boolean isCredentialsNonExpired =true;
    //账户是否可用（1 可用 0 删除用户）
    private boolean is_enabled =true;
    //用户权限字段的集合
    @TableField(exist = false)
    Collection<? extends GrantedAuthority> authorities;
}
